﻿using System;
using Gencode.VECore.VectorShape;

namespace Gencode.VECore.History
{
    /// <summary>
    /// Add new object command
    /// </summary>
    public class AddCommand : Command
    {
        VECShape _shape;

        /// <summary>
        /// Create this command with DrawObject instance added to the list
        /// </summary>
        /// <param name="drawObject"></param>
        public AddCommand(VECShape shape)
            : base()
        {
            // Keep copy of added object
            this._shape = shape.Clone();
        }

        public override void Undo(ShapeList list)
        {
            list.DeleteLastAddedObject();
        }

        public override void Redo(ShapeList list)
        {
            list.UnselectAll();
            list.Add(_shape);
        }
    }
}
